package com.example.designpatterns.Strategy.Cash;

/**
 * @author HUAWEI
 * 返利
 */
public class CashReturn extends CashSuper{
    private double moneyCondition = 0;
    private double moneyReturn = 0;

    public CashReturn(double moneyReturn, double moneyCondition) {
        this.moneyReturn = moneyReturn;
        this.moneyCondition = moneyCondition;
    }
    @Override
    public double acceptCash(double price, double num) {
        double result = price * num;
        if (moneyCondition > 0 && result >= moneyCondition) {
            result -= Math.floor(result / moneyCondition)*moneyReturn;
        }
        return result;
    }
}
